#数值类型 -- 整型、浮点型、 复数

# [root@sanchuang dev]# python3
# Python 3.6.8 (default, Nov 16 2020, 16:55:22)
# [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
# Type "help", "copyright", "credits" or "license" for more information.
# >>> a = 10
# >>> type(a)
# <class 'int'>
# >>> a = 999999999999999999999999999999999999999999999999999999999999999999999999999
# >>> type(a)
# <class 'int'>
# >>> b = 0b11
# >>> type(b)
# <class 'int'>
# >>> b
# 3
# >>> c = 0o13
# >>> type(c)
# <class 'int'>
# >>> c
# 11
# >>> d = 0x11
# >>> d
# 17
# >>> num = 100
# >>> bin(num)
# '0b1100100'
# >>> oct(num)
# '0o144'
# >>> hex(num)
# '0x64'
# >>> result = hex(num)
# >>> result
# '0x64'
# >>> int("123")
# 123
# >>> int(result, base=16)
# 100
# >>> 0xa
# 10
# >>> 0xb
# 11
# >>>

#浮点型 -- float
#不精确  -- 采用二进制存储
# >>> type(3.5)
# <class 'float'>
# >>> 1-0.1-0.1-0.1
# 0.7000000000000001

#decimal
from decimal import Decimal
# mydec = Decimal("3.22")
# mydec = Decimal(3.22)
# print(mydec, type(mydec))

#复数
# >>> a = -5 + 4j
# >>> a.real
# -5.0
# >>> a.imag
# 4.0
# >>> type(complex)
# <class 'type'>
# >>> type(a)
# <class 'complex'>
# >>> float("3.2")
# 3.2
# >>> int(3.2)
# 3
# >>> float(3)
# 3.0

###字符串类型
#定义 -- 单引号， 双引号 ， 三引号
# str1 = 'abc'
# str2 = "xyz"
# str3 = """
# keyi
# huanhang
# """
# print(str3, type(str3))
# >>> str(123)
# '123'
# >>> str(print)
# '<built-in function print>'
# >>> str = 100    #不要把内建函数作为变量名
# >>> str(123)
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: 'int' object is not callable
# >>> print = 100
# >>> print(123)
# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: 'int' object is not callable
# >>> if = 3
#   File "<stdin>", line 1
#     if = 3
#        ^
# SyntaxError: invalid syntax

##########转义字符  以\开头
# print("\ ")
# print("\"")
# print("\\")
# print("\a")
# print("a\nb")
# print("a\tb")
# print("a\\tb")
# print(r"a\tb")   #原始标记位， 不转义

################字符串的切片处理
#str[start:end:step]
#step 默认为1
#1、确定step为正还是为负
#    为正 从前往后截取
#    为负 从后往前截取
#2、确定start和end的位置，start在截取方向上要在end的前面
#3、确定步长

# str1 = "abc123456"
# print(str1[:4])
# print(str1[3:7])
# print(str1[6::-1])
# print(str1[-2:2:-2])
# print(str1[2:-2:-2])
# print(str1[4:-1])
# print(str1[::-1])

#字符串的拼接
#字符串级连
# str1 = "xyz" "abc"
# print(str1)
# str2 = "111" + "222"
# print(str2)
# str3 = "#@"*3
# print(str3)

#字符串格式化
#% 占位符格式化
# name = input("please input your name")
# school = input("please input your school")
#
# stu_info = "my name is %s, my school is %s"%(name, school)
# print(stu_info)

#%s -- 标志位  控制输出格式
# %s -- str
# %d -- 十进制整型
# %x -- 十六进制
# %o -- 八进制
# %f -- 浮点型表示
# %.2f -- 保留两位小数
# %%  -- 表示百分号本身

# num1 = 30
# print("二进制表示: %x"%num1)
# print("%.2f"%5.345235)
# print("%.3f%%"%(0.34553134 * 100))

#####format属性格式化
# name = input("please input your name")
# school = input("please input your school")
#
# format_str1 = "my name is {},my school is {}".format(name, school)
# print(format_str1)
# format_str2 = "my name is {1},my school is {0}".format(name, school)
# print(format_str2)
# format_str2 = "my name is {user},my school is {sch}".format(user=name, sch=school)
# print(format_str2)

#控制格式输出
# print('{0:x}'.format(30))

#python3 支持   -- f标志位格式
# name = "sctl"
# age = 18
#
# str1 = f"my name is {name}, my age is {age + 2}"
# print(str1)

#################python字符串的常用属性方法
# print( dir("xxx123") )
# #变量名.属性名   变量名.方法名() 以这种方式访问对象一系列属性方法
# print( f"是不是全为大写:{ 'xxABC'.isupper() }")
# print( f"是不是为标题字符:{ 'A Beautiful girl'.istitle() }")
# print( f"判断开始字符: { 'abc123'.startswith('abc') }")
# #判断某一段范围内是不是以abc开始
# print( f"判断开始字符: { 'abc123'.startswith('abc',3) }")
# print( f"判断结束字符: { 'abc123'.endswith('123')}")

#从键盘接受用户输入，判断输入是否为整型，包括十进制，二进制，八进制，十六进制
# num1 = input("please input an number:")
#
# num1_pre = num1[:2]
# if num1_pre == "0b" or num1_pre == "0o" or num1_pre == "0x" or num1_pre.isdigit():
#     if num1[2:0].isdigit():
#         print("是整型")
#     else:
#         print("不是整型")
# else:
#     print("不是整型")

#字符串的遍历
# for i in "abc":
#     print("*"*10)
#     print(i)

#判断成员关系
# print("a" in "abc")
# print("abd" not in "abc")

#进阶
num1 = input("please input an number:")

num1_pre = num1[:2]
if num1_pre == "0b":
    patter_str = "01"
elif num1_pre == "0o":
    patter_str = "01234567"

for i in num1[2:]:
    flag = 0  # 标志位
    if i not in patter_str:
        flag = 1  #发生事情，标志位改变
        break   #退出当前循环
if flag == 0 or num1.isdigit():  #判断有没有发生过
    print("输入是整型")
else:
    print("输入不是整型")
